#!/bin/sh
# Debian kvm package pre-installation script
# Copyright (C) 2007 Leonard Norrgard, Refactor, Finland
# Licensed under the GNU General Public License, version 2.  See the file
# /usr/share/common-licenses/GPL or <http://www.gnu.org/copyleft/gpl.txt>.

# Remove a no-longer used conffiles
rm_existing_file() {
	CHECK="$1"
	FILENAME="$2"
	if [ "$CHECK" "$FILENAME" ]; then
		rm -f "$FILENAME"
	fi
}

LASTVERSION=28-2
case "$1" in
install|upgrade)
    if dpkg --compare-versions "$2" le "$LASTVERSION"; then
        rm_existing_file -e "/etc/udev/kvm.rules"
	rm_existing_file -L "/etc/udev/rules.d/z60_kvm.rules"
    fi

    if [ -e "/etc/udev/rules.d/45-kvm.rules" ]; then
	if [ "`md5sum \"/etc/udev/rules.d/45-kvm.rules\" | sed -e \"s/ .*//\"`" = \
	     "`dpkg-query -W -f='${Conffiles}' kvm | sed -n -e \"\\\\' /etc/udev/rules.d/45-kvm.rules's/.* //p\"`" ]
	then
		rm -f "/etc/udev/rules.d/45-kvm.rules"
	fi
    fi
esac

#DEBHELPER#

exit 0
